async function fetchWithAsyncTimeout(url, options, timeout = 5000) {
    const controller = new AbortController();
    const { signal } = controller;

    try {
        const timeoutId = setTimeout(() => {
            controller.abort();
            throw new Error("Request timeout");
        }, timeout);

        const response = await fetch(url, { ...options, signal });
        clearTimeout(timeoutId); // 请求成功，取消超时计时器
        return response.json();
    } catch (error) {
        console.error(error.message); // 超时或请求失败
    }
}

// 使用示例
fetchWithAsyncTimeout("https://api.example.com/data", {}, 3000)
    .then(data => console.log(data))
    .catch(error => console.error(error));